<?php

class Talktangle_Form_Crosstangle_Create extends Engine_Form
{
  private $_type = null;
  
      
  public function init()
  {
      $this->setAttrib('id','form_create_crosstangle');
     $view = Zend_Registry::get('Zend_View');
      $this->clearDecorators()
//      ->addDecorator('FormElements')
//      ->addDecorator('Form')
      ->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));

        $this->setTitle('Create Crosstangle');
        
        $this->addElement('text','title',array(
            'label'=>'Title',
            'description' => $view->translate('This is will show on feed, when you post new tangle.'),
			'required' =>true,
            
            'allowEmtry'=>false,
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)                                             
        ));
        
        $core = Engine_Api::_()->talktangle();
        
        if($core->enableTiwtter()){
            $this->addElement('checkbox','post_tiwtter',array(
                'label' => 'send to tiwtter'
            )) ;
        }
        
         if($core->enableFacebook()){
            $this->addElement('checkbox','post_facebook',array(
                'label' => 'send to facebook'
            )) ;
        }
        $this->addElement('heading','heading1',array(
                'label' => 'Letter Info 1',
                'class' => 'heading-wrapper'
            )
        ); 
        
              
        $this->addElement('text','content1',array(
            'label'=>'Letter',
            
			'required' =>false,
            'description' => 'This is text that you want user looking.',
                                                       
        ));
        
        $this->addElement('text','description1',array(
            'label'=>'Description',
			'required' =>false,
            'description' => 'This is text that will suggest user to looking you letter.',
                                                        
        ));
        
        
        $this->addElement('Cancel','addletter',array(
                'label' => 'Add letter',
                'link' => true, 
    			'href' => '',
                'onclick' => 'addNewLetter()'
        
            )
        );
        
        
        
       /* $this->addElement('TinyMce','description',array(
            'label'=>'Description',
			'required' =>true,
            'allowEmtry'=>false,
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)
        ));*/
        
        if ( $this->_type == 'company') {
            $this->addElement('select','duration',array(
                'label'=>'Duration',
                'multiOptions' => array(
                    '1' => '1 Day',
                    '2' => '1 Week',
                    '3' => '1 Month',               
                ),                               
            ));
            
            $this->addElement('heading','heading_promotion',array(
                    'label' => 'Promotion',
                    'class' => 'promotion-wrapper'
                )
            );
            
            $this->addElement('text','promotion_title',array(
                'label' => 'Promotion title',
                'description' => 'Title of promotion, When user untangle success they give this promotion'
                
            ));
            $this->addElement('text','promotion_description',array(
                'label' => 'Promotion description',
                'description' => 'Title of promotion, When user untangle success they give this promotion'
                
            ));
            
            $this->addElement('file', 'promotion_image', array (
    			'label' => 'Promotion image', 
                'onchange' => 'uploadPromotion()',
    			
    		)); 
            $this->addElement('hidden','promotion_id',array('order'=>1000));
            
            
                
            
            $this->addElement('heading','heading_ads',array(
                    'label' => 'Ads',
                    'class' => 'ads-wrapper'
                )
            ); 
            
             
            $this->addElement('Text','ads_description',array(
                'label'=>'Ads Description',
    			'onkeyup' =>'keyUpAdsDescription(this)',
                
                
            ));
            $this->addElement('file', 'image_upload', array (
    			'label' => 'Ads image', 
                'onchange' => 'uploadAds()',
    			
    		));
            
            $this->addElement('Cancel','preview_ads',array(
                    
                    'link' => true, 
        			'href' => ''
                    
            
                )
            );  
            $this->addElement('hidden','imageId',array('order'=>1001));
            
        
       }
       	
       $this->addElement('Button', 'submit', array (
			'label' => 'Submit', 
			'type' => 'submit',
            'onclick' => 'return checkValidSubmitForm();',
			'decorators' => array (
				'ViewHelper'
			)
		)); 
       
		$this->addElement('Cancel', 'cancel', array (
				'label' => 'cancel', 
				'link' => true, 
				'href' => '', 
                'onclick' => 'cancelCreate();',
				'decorators' => array (
						'ViewHelper'
				)
		));               

        $this->addDisplayGroup(array('submit', 'cancel'), 'buttons', array(
          'decorators' => array(
            'FormElements',
            'DivDivDivWrapper',
          ),
        ));           
  }
  
  public function setType($type){
    $this->_type = $type;
  }
  public function getType(){
    return $this->_type;
  }
  
  public function isUploadAdvertise(){
     return true;
  }
}  